<template>
  <div>
    <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="80%" v-dialog-drag append-to-body>
      <!-- 搜索工作栏 -->
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
        <el-form-item label="物料名称" prop="materialName">
          <el-input v-model="queryParams.materialName" placeholder="请输入物料名称" clearable
                    @keyup.enter.native="handleQuery"/>
        </el-form-item>
        <el-form-item label="产品码" prop="materialCode">
          <el-input v-model="queryParams.materialCode" placeholder="请输入产品码" clearable
                    @keyup.enter.native="handleQuery"/>
        </el-form-item>
        <el-form-item label="客户零件号" prop="partNumber">
          <el-input v-model="queryParams.partNumber" placeholder="请输入客户零件号" clearable
                    @keyup.enter.native="handleQuery"/>
        </el-form-item>
        <el-form-item label="零件简号" prop="partNumberShort">
          <el-input v-model="queryParams.partNumberShort" placeholder="请输入零件简号" clearable
                    @keyup.enter.native="handleQuery"/>
        </el-form-item>
<!--        <el-form-item label="物料代码" prop="modeCode">-->
<!--          <el-input v-model="queryParams.modeCode" placeholder="请输入物料代码" clearable-->
<!--                    @keyup.enter.native="handleQuery"/>-->
<!--        </el-form-item>-->
        <el-form-item label="物料箱编码" prop="boxCode">
          <el-input v-model="queryParams.boxCode" placeholder="请输入物料箱编码" clearable
                    @keyup.enter.native="handleQuery"/>
        </el-form-item>
<!--        <el-form-item label="托盘编码" prop="trayCode">-->
<!--          <el-input v-model="queryParams.trayCode" placeholder="请输入托盘编码" clearable-->
<!--                    @keyup.enter.native="handleQuery"/>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="所在仓库" prop="warehouseId">-->
<!--          <el-select v-model="queryParams.warehouseId" placeholder="请选择所在仓库" clearable size="small">-->
<!--            <el-option v-for="warehouse in warehouseList" :key="warehouse.id" :label="warehouse.name"-->
<!--                       :value="warehouse.id"/>-->
<!--          </el-select>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="入库时间" prop="entryTime">-->
<!--          <el-date-picker v-model="queryParams.entryTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"-->
<!--                          type="daterange"-->
<!--                          range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"-->
<!--                          :default-time="['00:00:00', '23:59:59']"/>-->
<!--        </el-form-item>-->
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>

      <!-- 操作工具栏 -->
      <el-row :gutter="10" class="mb8">
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>

      <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
        <el-table-column type="index" label="序号" align="center" width="50"/>
        <el-table-column label="产品码" align="center" prop="materialCode"/>
        <el-table-column label="物料代码" align="center" prop="materialModeCode"/>
        <el-table-column label="客户零件号" align="center" prop="partNumber"/>
        <el-table-column label="零件简号" align="center" prop="partNumberShort"/>
        <el-table-column label="物料箱编码" align="center" prop="boxCode" min-width="100"/>
        <el-table-column label="托盘编码" align="center" prop="trayCode"/>
      </el-table>
      <!-- 分页组件 -->
      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                  @pagination="getList"/>
    </el-dialog>
  </div>
</template>
<script>
import {getWarehouseSimpleList} from "@/api/hs/warehouse";
import {getPickTaskMaterialDetailPage} from "@/api/hs/picktaskmaterialdetail";

export default {
  name: "ShipOrderDetail",
  components: {},
  data() {
    return {
      // 弹出层标题
      dialogTitle: "",
      // 是否显示弹出层
      dialogVisible: false,
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 入库单明细列表
      list: [],
      // 是否展开，默认全部展开
      isExpandAll: true,
      // 重新渲染表格状态
      refreshTable: true,
      // 选中行
      currentRow: {},
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        orderId: null,
        materialName: null,
        materialCode: null,
        modeCode: null,
        boxCode: null,
        trayCode: null,
        warehouseId: null,
        entryTime: [],
        createTime: [],
        partNumber: null,
        partNumberShort: null
      },
      warehouseList: []
    };
  },
  methods: {
    /** 打开弹窗 */
    async open(shipOrderId) {
      this.dialogVisible = true;
      this.dialogTitle = "出库单明细";
      this.queryParams.shipOrderId = shipOrderId;
      await this.getList();
    },
    /** 查询列表 */
    async getList() {
      try {
        this.loading = true;
        const res = await getPickTaskMaterialDetailPage(this.queryParams);
        this.list = res.data.list;
        this.total = res.data.total;
      } finally {
        this.loading = false;
      }
    },
    /** 搜索按钮操作 */
    async handleQuery() {
      this.queryParams.pageNo = 1;
      await this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
<style scoped lang="scss">

</style>
